package net.esj.auth.inst.hibernate.dependent.background.menu;

import java.io.Serializable;
import java.util.LinkedHashSet;
import java.util.Set;

import net.esj.auth.pojo.CoreAuthFunc;
import net.esj.background.support.BgMenu;

public class AuthMenu implements BgMenu,Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 6538211328158077101L;
	
	private String id;
	private String parentId;
	private String ico;
	private String name;
	private String url;
	private Set<BgMenu> children;
	private boolean isMenu;
	private boolean isOpen = false;
	
	public AuthMenu(CoreAuthFunc func) {
		this.id = func.getId();
		this.ico = func.getIcon();
		if(func.getParent()!=null){
			this.parentId = func.getParent().getId();
		}
		this.name = func.getName();
		this.url = func.getUrl();
		this.isMenu = func.getIsMenu();
		this.children = new LinkedHashSet<BgMenu>();
//		for(CoreAuthFunc cf: func.getChildren()){
//			this.children.add(new AuthMenu(cf));
//		}
	}
	
	@Override
	public String getIco() {
		return ico;
	}

	@Override
	public boolean isMenu() {
		return isMenu;
	}

	@Override
	public boolean isOpen() {
		return isOpen;
	}

	@Override
	public Set<BgMenu> getChildMenus() {
		return children;
	}

	@Override
	public String getName() {
		return name;
	}

	@Override
	public String getUrl() {
		return url;
	}

	@Override
	public String getId() {
		return id;
	}

	@Override
	public String getParentId() {
		return parentId;
	}

}
